$(document).ready(function(){
	var prefix = "http://localhost/eaters-website/";
	var difficultyData = {'新手':0,'初级':1,'初中':2,'中级':3,'高级':4,'厨神':5}

	$("#selector").click(function(){
		$("#selectorList").toggle();
	})

	$("#selectorList li").click(function(){
		$("#selector").text($(this).text()+"▼");
		$("#field").val($(this).attr('val'));
		$("#selectorList").toggle();
	})

	$("#recipeTags a").each(function(){
		$(this).attr('href',prefix+'recipes/search/?field=tags&order=createdTime&query='+$(this).text());
	})
	
	$(".recipeItemTags a").each(function(){
		$(this).attr('href',prefix+'recipes/search/?field=tags&order=createdTime&query='+$(this).text());
	})

	$(".recipeItemTaste a").each(function(){
		$(this).attr('href',prefix+'recipes/search/?field=taste&order=createdTime&query='+$(this).text());
	})

	$(".recipeItemMethod a").each(function(){
		$(this).attr('href',prefix+'recipes/search/?field=method&order=createdTime&query='+$(this).text());
	})

	$(".recipeItemDifficulty a").each(function(){
		$(this).attr('href',prefix+'recipes/search/?field=Difficulty&order=createdTime&query='+difficultyData[$(this).text()]);
	})

	
})